#!/usr/bin/env python
# encoding: utf-8


"""
  @author: gaogao
  @file: calcu_step_util.py
  @time: 2020/11/18 17:54
  @desc:
"""
import numpy as np


def get_points_list(start_value, stop_value, points_num):
    if float(stop_value) > float(start_value):
        step = abs((float(stop_value) - float(start_value)) / (float(points_num) - 1))
        data_list = [float(start_value) + i * step for i in range(int(points_num))]
        if data_list:
            return data_list
    elif float(stop_value) < float(start_value):
        step = abs(((float(stop_value)) - float(start_value)) / (
                float(points_num) - 1))
        data_list = [float(start_value) - i * step for i in range(int(points_num))]
        if data_list:
            return data_list
    else:
        data_list = [float(start_value)]
        return data_list


def get_step_list(start_value, stop_value, step_value):
    if float(stop_value) > float(start_value):
        points_num = abs((float(stop_value) - float(start_value)) / (
            float(step_value))) + 1
        data_list = [round(float(start_value) + i * float(step_value), 3) for i in range(int(points_num))]
        if data_list:
            return data_list
    elif float(stop_value) < float(start_value):
        points_num = abs((float(stop_value) - float(start_value)) / (
            float(step_value))) + 1
        data_list = [round(float(start_value) - i * float(step_value), 3) for i in range(int(points_num))]
        if data_list:
            return data_list
    else:
        data_list = [float(start_value)]
        return data_list


def get_step_array(start, stop, step):
    array_list = np.arange(start, stop, step)
    array_list = [str(i) for i in array_list]
    array_list.append(str(stop))
    return array_list


def get_points_array(start, stop, points):
    array_list = np.linspace(start, stop, points)
    array_list = [str(i) for i in array_list]
    return array_list


# data_list = get_points_array(0.5, 1.5, 60)
# print(len(data_list),type(data_list), data_list)
# print(get_step_array(0.0, 1.5, 0.1))
